<!DOCTYPE html>
<html>
   <head>
      <title>报工单</title>
      <meta name="viewport" content="width=device-width, initial-scale=1.0 Access-Control-Allow-Origin">
      <!-- 引入 Bootstrap -->
      <!--<link href="<?=base_url('html/bootstrap_v3/css/bootstrap.css')?>" rel="stylesheet">-->
      <link href="<?=  base_url('/html/bootstrap_v3/css/bootstrap.css')?>" rel="stylesheet">
      <link href="<?=base_url('html/bootstrap_v3/datepicker/css/bootstrap-datetimepicker.min.css')?>" rel="stylesheet">
      <script src="<?=base_url('html/js/jquery-1.8.3.min.js')?>"></script>
      <script src="<?=base_url('html/bootstrap_v3/js/bootstrap.min.js')?>"></script>
      <script src="<?=base_url('html/bootstrap_v3/datepicker/js/bootstrap-datetimepicker.js')?>"></script>
      <script src="<?=base_url('html/bootstrap_v3/datepicker/js/locales/bootstrap-datetimepicker.zh-CN.js')?>"></script>
      <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
      <script type="text/javascript">
          $(document).ready(function(){
              $("#finish").click(function(){
                  $(".selectType").css("display","none");
                  $(".baogongFinish").css("display","block");
              });
              $("#check").click(function(){
                  $(".selectType").css("display","none");
                  $(".baogongCheck").css("display","block");
              });
              $(".backbutton").click(function(){
                  $(".selectType").css("display","block");
                  $(".baogongFinish").css("display","none");
                  $(".baogongCheck").css("display","none");
              });
              $(".FinishSearch").click(function(){
                    var LZKNO       = $("#finish_cardno").val();
                    var UserName    = $("#finish_UserName").val();
                    var UserNo      = $("#finish_UserNo").val();
                    if(LZKNO.length > 0){
                        window.location.href = "<?=  base_url("baogongFinish/GetTaskingByJsonByLZKNO?UserName=")?>"+UserName+"&UserNo="+UserNo+"&LZKNO="+LZKNO;
                    }else{
                        alert("请先扫描条码或输入流转卡号！");
                    }
                    
              });
              $(".CheckSearch").click(function(){
                    var MatterNo   = $("#check_matterno").val();
                    var UserNo   = $("#check_UserNo").val();
                    var UserName = $("#check_UserName").val();
                    //alert("UserNo = " + UserNo + "&UserName = " + UserName);
                    if(MatterNo.length > 0){
                        window.location.href = "<?=  base_url("baogongFinish/GetTaskingByJsonByMatterNo?MatterNo=")?>"+MatterNo+"&UserNo="+UserNo+"&UserName="+UserName;
                    }else{
                        alert("请先扫描条码或输入物料代码！");
                    }
              });
          })
      </script> 
      <script>
          /*
           * 注意：
           * 1. 所有的JS接口只能在公众号绑定的域名下调用，公众号开发者需要先登录微信公众平台进入“公众号设置”的“功能设置”里填写“JS接口安全域名”。
           * 2. 如果发现在 Android 不能分享自定义内容，请到官网下载最新的包覆盖安装，Android 自定义分享接口需升级至 6.0.2.58 版本及以上。
           * 3. 常见问题及完整 JS-SDK 文档地址：http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html
           *
           * 开发中遇到问题详见文档“附录5-常见错误及解决办法”解决，如仍未能解决可通过以下渠道反馈：
           * 邮箱地址：weixin-open@qq.com
           * 邮件主题：【微信JS-SDK反馈】具体问题
           * 邮件内容说明：用简明的语言描述问题所在，并交代清楚遇到该问题的场景，可附上截屏图片，微信团队会尽快处理你的反馈。
           */
          wx.config({
            debug: false,
            appId: '<?=$appId;?>',
            timestamp: <?=$timestamp;?>,
            nonceStr: '<?=$nonceStr;?>',
            signature: '<?=$signature;?>',
            jsApiList: [
              // 所有要调用的 API 都要加到这个列表中
              'scanQRCode',
              'chooseImage',
              'previewImage',
              'uploadImage',
              'downloadImage',
              'translateVoice'
            ]
          });
          wx.ready(function () {
            // 在这里调用 API
            document.querySelector('.finish_cardno').onclick = function () {
                wx.scanQRCode({
                  needResult: 1,
                  desc: 'scanQRCode desc',
                  success: function (res) {
                    //alert(JSON.stringify(res));
                    var result = res.resultStr;
                    /*
                    $.ajax({
                       type:"GET",
                       url:"<?=base_url()?>/baogong/getSoapBarCodeType?value="+result,
                       dataType:"json",
                       success:function(data){
                           if(data.type === "LZK"){
                               $("#finish_cardno").val(data.msg1);
                               
                           }else if(data.type === "Emp"){
                               $("#finish_UserNo").val("E"+data.msg1);
                               $("#finish_UserName").val(data.msg2);
                               
                           }else{
                               alert("系统中不存在该流转卡号，请您确认您输入的流转卡信息是否有误！");
                           }
                       },
                        error: function(XMLHttpRequest, textStatus, errorThrown) {
                                    //alert(XMLHttpRequest.status);
                                    //alert(XMLHttpRequest.readyState);
                                    //alert(textStatus);
                                    alert("您更新的信息有误，请重新确认或联系管理员！");
                        }
                   });
        */
                    $("#finish_cardno").val(result);
                    //window.location.href = "<?=  base_url("baogongFinish/showMsg?cardno=")?>"+result+"&type=finish&username="+username+"&userid="+userid;
                  }
                });
            };
            document.querySelector('.finish_userno').onclick = function () {
                wx.scanQRCode({
                  needResult: 1,
                  desc: 'scanQRCode desc',
                  success: function (res) {
                    var result = res.resultStr;
                    /*
                    $.ajax({
                       type:"GET",
                       url:"<?=base_url()?>/baogong/getSoapBarCodeType?value="+result,
                       dataType:"json",
                       success:function(data){
                           if(data.type === "LZK"){
                               $("#finish_cardno").val(data.msg1);
                              
                           }else if(data.type === "Emp"){
                               $("#finish_UserNo").val("E"+data.msg1);
                               $("#finish_UserName").val(data.msg2);
                               
                           }else{
                               alert("系统中不存在该流转卡号，请您确认您输入的流转卡信息是否有误！");
                           }
                       },
                        error: function(XMLHttpRequest, textStatus, errorThrown) {
                                    //alert(XMLHttpRequest.status);
                                    //alert(XMLHttpRequest.readyState);
                                    //alert(textStatus);
                                    alert("您更新的信息有误，请重新确认或联系管理员！");
                        }
                   });*/
                    $("#finish_cardno").val(result);
                  }
                });
            };
            document.querySelector('.check_matterno').onclick = function () {
                wx.scanQRCode({
                  needResult: 1,
                  desc: 'scanQRCode desc',
                  success: function (res) {
                    //alert(JSON.stringify(res));
                    var result = res.resultStr;
                    $.ajax({
                       type:"GET",
                       url:"<?=base_url()?>/baogong/getCodeType?value="+result,
                       dataType:"json",
                       success:function(data){
                           if(data.type==="matter"&data.res==="true"){
                               $("#check_matterno").val(data.matterno);
                           }else if(data.type==="user"&data.res==="true"){
                               $("#check_UserNo").val("E"+data.userno);
                               $("#check_UserName").val(data.username);
                           }else{
                               alert("请选择正确的物料号或者员工工号扫描输入！");
                           }
                       },
                        error: function(XMLHttpRequest, textStatus, errorThrown) {
                                    //alert(XMLHttpRequest.status);
                                    //alert(XMLHttpRequest.readyState);
                                    //alert(textStatus);
                                    alert("您更新的信息有误，请重新确认或联系管理员！");
                        }
                   });
                  }
                });
            };
            document.querySelector('.check_userno').onclick = function () {
                wx.scanQRCode({
                  needResult: 1,
                  desc: 'scanQRCode desc',
                  success: function (res) {
                    //alert(JSON.stringify(res));
                    var result = res.resultStr;
                    $.ajax({
                       type:"GET",
                       url:"<?=base_url()?>/baogong/getCodeType?value="+result,
                       dataType:"json",
                       success:function(data){
                           if(data.type==="matter"&data.res==="true"){
                               $("#check_matterno").val(data.matterno);
                           }else if(data.type==="user"&data.res==="true"){
                               $("#check_UserNo").val("E"+data.userno);
                               $("#check_UserName").val(data.username);
                           }else{
                               alert("请选择正确的物料号或者员工工号扫描输入！");
                           }
                       },
                        error: function(XMLHttpRequest, textStatus, errorThrown) {
                                    //alert(XMLHttpRequest.status);
                                    //alert(XMLHttpRequest.readyState);
                                    //alert(textStatus);
                                    alert("您更新的信息有误，请重新确认或联系管理员！");
                        }
                   });
                  }
                });
            };
          });
        </script>
<style type="text/css">
    .baogongCheck{display: none}
    .baogongFinish{display:none;}
    .form-group{margin-top: 15px;}
</style> 
      
      <!-- HTML5 Shim 和 Respond.js 用于让 IE8 支持 HTML5元素和媒体查询 -->
      <!-- 注意： 如果通过 file://  引入 Respond.js 文件，则该文件无法起效果 -->
      <!--[if lt IE 9]>
         <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
         <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
      <![endif]-->
   </head>
   <body>
       <?php if($status == "开通"):?>
            <div class="container">
            <div style="margin-top: 50px;"></div>

                 <!--完工报工-->
                 <div class="form-group baogongFinish">
                          <lable class="col-xs-3 span3 control-label">
                              流转卡号:
                          </lable>
                          <div class="input-group col-xs-9 span9">
                              <input type="text" class="form-control" rows="2" id="finish_cardno" placeholder="请输入流转卡号或扫码输入">
                              <span class="input-group-addon">
                                 <span class="glyphicon glyphicon-qrcode finish_cardno"> </span>
                             </span>
                          </div>
                 </div>
                 <div class="form-group baogongFinish" style="padding-top: 60px;">
                          <lable class="col-xs-3 span3 control-label">
                              员工工号:
                          </lable>
                          <div class="input-group col-xs-9 span9">
                              <input type="text" class="form-control" rows="2" id="finish_UserNo" value="<?=$EmpUserNo?>" placeholder="请输入员工工号">
                              <span class="input-group-addon">
                                 <span class="glyphicon glyphicon-qrcode finish_userno"> </span>
                             </span>
                          </div>
                  </div>
                 <div class="form-group baogongFinish" style="padding-top: 60px;">
                          <lable class="col-xs-3 span3 control-label">
                              员工姓名:
                          </lable>
                          <div class="input-group col-xs-9 span9">
                              <input type="text" class="form-control" rows="2" id="finish_UserName" value="<?=$EmpUserName?>" readonly="readonly">
                          </div>
                  </div>
                 <div class="form-group" style="margin-bottom: 60px"></div>
                 
                 <button id="finishSao" type="button" class="btn btn-primary btn-block btn-lg baogongFinish FinishSearch">
                         确定查询(完工报工)
                 </button>
                <button type="button" class="btn btn-primary btn-block btn-lg backbutton baogongFinish" style="margin-top: 20px">
                    返回
                 </button>
                 <!--质检报工-->
                <div class="form-group baogongCheck">
                    <lable class="col-xs-3 span3 control">
                              物料号:
                     </lable>
                     <div class="input-group col-xs-9 span9">
                         <input type="text" class="form-control" rows="2" id="check_matterno" placeholder="输入物料号或扫码输入">
                         <span class="input-group-addon">
                             <span class="glyphicon glyphicon-qrcode check_matterno"> </span>
                         </span>
                     </div>
                </div>
                <div class="form-group baogongCheck" style="padding-top: 60px;">
                          <lable class="col-xs-3 span3 control">
                              员工工号:
                          </lable>
                          <div class="input-group col-xs-9 span9">
                              <input type="text" class="form-control" rows="2" id="check_UserNo" value="<?=$EmpUserNo?>" placeholder="请输入员工工号">
                              <span class="input-group-addon">
                                 <span class="glyphicon glyphicon-qrcode check_userno"> </span>
                             </span>
                          </div>
                  </div>
                 <div class="form-group baogongCheck" style="padding-top: 60px;">
                          <lable class="col-xs-3 span3 control-label">
                              员工姓名:
                          </lable>
                          <div class="input-group col-xs-9 span9">
                              <input type="text" class="form-control" rows="2" id="check_UserName" value="<?=$EmpUserName?>" readonly="readonly">
                          </div>
                  </div>
                 <div class="form-group" style="margin-bottom: 60px"></div>
                 
                 <button id="CheckSao" type="button" class="btn btn-primary btn-block btn-lg baogongCheck CheckSearch">
                     确定查询(质检报工)
                  </button>
                 <button type="button" class="btn btn-primary btn-block btn-lg backbutton baogongCheck" style="margin-top: 20px">
                     返回
                  </button>
                 <!--报工选择界面-->
            <div class="selectType">
                 <p>
                     <button id="finish" type="button" class="btn btn-primary btn-lg btn-block">
                        完工报工
                     </button>
                 </p>
                 <hr>
                 <p>
                     <button id="check" type="button" class="btn btn-primary btn-lg btn-block">
                        质检报工
                     </button>
                 </p>
            </div>
            </div>
       <?php else :?>
       <div>
           <p style="color: red;font-weight: bold;margin-top: 50px;">
               对不起，你的账号还未开通MES模块权限，请联系管理员开通相关权限后使用！
           </p>
       </div>
       <?php endif;?>
   </body>
</html>